package com.glg.springmvc;

import jakarta.websocket.server.PathParam;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


@RestController
public class RequestController {

    @RequestMapping("/hello")
    public String say(){
        return "hello, spring mvc";
    }

    @RequestMapping("/r1")
    public String r1(int age) {
        return "接收到参数，age="+age;
    }

    @RequestMapping("/r2")
    public String r2(String name, Integer age){
        return "接收到参数，name="+name+"age="+age;
    }

    @RequestMapping("/r3")
    public String r3(Student student) {
        return "接收到参数，student："+student;
    }

    @RequestMapping("/article/{articleId}")
    public String r4(@PathVariable("articleId") Integer articleId) {
        return "收到参数：articleId：" + articleId;
    }

    /**
     * 上传文件
     * @param file
     * @return
     */
    @RequestMapping("/r5")
    public String r5(MultipartFile file){
        String originalFilename = file.getOriginalFilename();
        return "接收到文件，文件名称："+originalFilename;
    }

}







